Quiz 12
Question # 1
Which statements are true for Heap tables?
A)
Heap tables require special privileges.
B)
Heap tables last in memory till you restart your database.
C)
Heap tables are shared among clients.
D)
Heap tables use indexes.
Question # 2
Suppose we have a table of test scores as follows:
ScoreTable
Score |
---|
2 |
-4 |
-2 |
3 |
0 |
1 |
Which single query will calculate the sum of all positive values of Score and the sum of all negative values of Score table?
A)
SELECT SUM(SELECT * FROM ScoreTable WHERE Score > 0) PositiveScore , SUM(SELECT * FROM ScoreTable WHERE Score < 0) NegativeScore;
B)
SELECT SUM(Score) FROM ScoreTable WHERE Score > 0 AND SELECT SUM(Score) FROM Score Table WHERE Score < 0;
C)
SELECT SUM(CASE WHEN Score > 0 THEN SCORE ELSE 0 END) PositiveScore, SUM(CASE WHEN Score < 0 THEN Score ELSE 0 END) NegativeScore FROM ScoreTable;
Question # 3
Which query/ queries can help you find the last ID from tableA?
A)
SELECT ID FROM tableA ORDER BY ID DESC LIMIT 1;
B)
SELECT ID FROM tableA ORDER BY ID ASC LIMIT 1;
C)
SELECT LAST(ID) FROM tableA;
D)
SELECT MAX(ID) FROM TableA;
Question # 4
Suppose we have a table as follows:
Table A
Number |
---|
1 |
2 |
3 |
4 |
5 |
What will be the outcome of the following SELECT queries:
SELECT SUM(1) FROM tableA;
SELECT SUM(2) FROM tableA;
SELECT SUM(3) FROM tableA;
A)
1 2 3
B)
5 10 15
C)
The SELECT statements will give an error
Question # 5
Suppose we have a Voters table having 1000 records. What will be the outcome when the following code is executed?
START TRANSACTION;
TRUNCATE TABLE Voters;
ROLLBACK;
SELECT * FROM Voters;
A)
The query returns 1000 records because START TRANSACTION maintains a log.
B)
The query returns an Empty Set as the Voters Table was truncated.